<template>
    <div class="putQuestionsBox">
        <div class="problem">
            <el-input type="textarea" maxlength="40" :show-word-limit="true" :rows="2" placeholder="请在这里描述你的问题"
                v-model="title">
            </el-input>
        </div>
        <div class="problems">
            <el-input type="textarea" maxlength="200" :show-word-limit="true" :rows="10" placeholder="请在这里补充你的问题"
                v-model="content">
            </el-input>
            <!-- <div class="upload">
                <el-button size="mini" type="primary" icon="el-icon-picture"></el-button>
            </div> -->
        </div>
        <div class="btnSubmit">
            <el-button type="primary" @click="subQuetion">提交问题</el-button>
        </div>
    </div>
</template>

<script>
    import {
        mapState
    } from 'vuex'
    export default {
        name: "studentPutQuestions",
        computed: {
            ...mapState({
                userInfo: state => state.userModule.userInfo
            })
        },
        data() {
            return {
                content: '',
                title: ''
            }
        },
        methods: {
            // 提交问题
            subQuetion() {
                this.$store.dispatch('invitationModule/questions', {
                    userid: this.userInfo.id,
                    content: this.content,
                    title: this.title
                }).then(res => {
                    if (res.data.code === 200) {
                        this.$message.success('提问成功');
                        this.$router.push({
                            path: "/students/studentQuestions"
                        });
                    }
                })
            },
            handleRemove(file, fileList) {
            },
            handlePreview(file) {
            }
        }
    }
</script>

<style lang="scss" scoped>
    .putQuestionsBox {
        width: 100%;
        box-sizing: border-box;
        padding: 15px;
        margin: 0 auto;
        background-color: white;

        .problems {
            margin-top: 40px;
            position: relative;

            .upload {
                position: absolute;
                left: 10px;
                bottom: 10px;
            }
        }

        .btnSubmit {
            text-align: right;
            margin-top: 18px;
        }
    }
</style>